package me.xhy.java.springboot3.r2dbc.s04repository;

import me.xhy.java.springboot3.r2dbc.s04repository.s044repository.S044Demo1Repository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.concurrent.TimeUnit;

@SpringBootTest(classes = S041Application.class)
public class S044Test {

  /*
  1. 一般应用
  2. QBE API： query by example
  3. 自定义方法
  4. 自定义SQL
   */

  @Autowired
  private S044Demo1Repository repository;

  @Test
  void test1() throws Exception {
    repository.findAll()
        .subscribe(System.out::println);

    TimeUnit.SECONDS.sleep(10);
  }

  // 仅限单表可用
  @Test
  void test2 () throws Exception {
    repository.findAllByIdInAndTenantIdLike(
        new Long[]{1801610513433604098L,1801610825749868545L}, "0%")
        .subscribe(System.out::println);

    TimeUnit.SECONDS.sleep(10);
  }

  @Test
  void test3 () throws Exception {
    repository.findBySql1()
        .subscribe(System.out::println);

    TimeUnit.SECONDS.sleep(10);
  }
}
